package training.sample.app.security;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import training.sample.app.domain.UserAccount;

import java.util.Collection;

public class ApplicationUserDetails extends User {
	
	private static final long serialVersionUID = 98078L;
	private UserAccount userPrincipal;

	public ApplicationUserDetails(
			String username, String password,
			boolean enabled, 
			boolean accountNonExpired,
			boolean credentialsNonExpired, 
			boolean accountNonLocked,
			Collection<? extends GrantedAuthority> authorities) {
		
		super(username, password, enabled, accountNonExpired,
				credentialsNonExpired, accountNonLocked, authorities);
	}

	public ApplicationUserDetails(
			UserAccount user,
			Collection<GrantedAuthority> authorities) {
		super(user.getLogin(), user.getPassword(), authorities);

		this.userPrincipal = user;
	}

	public UserAccount getAccount() {
		return userPrincipal;
	}

	public void setAccount(UserAccount userPrincipal) {
		this.userPrincipal = userPrincipal;
	}
}
